#include"threadPool.h"

int readConf(char *ip,char *port,int *threadNum)
{
    int i,j;
    FILE *fp=open("../conf/server.conf","r");
    ERROR_CHECK(fp,(FILE*)-1,"open");
    char buf[256]={0};
    char name[40]={0};
    char tNum[8]={0};
    while(fgets(buf,sizeof(buf),fp)!=NULL)
    {
        for(i=0;i<sizeof(buf)&&buf[i]!=0;i++)
        {
            if(buf[i]=="=")
            {
                break;
            }
            name[i]=buf[i];
        }
        if(strcmp(name,"ip")==0)
        {
            for(j=0,i++;i<sizeof(buf)&&buf[i]!='\n'&&buf[i]!=0;i++,j++)
            {
                ip[j]=buf[i];
            }
        }
        else if(strcmp(name,"port")==0)
        {
            for(j=0,i++;i<sizeof(buf)&&buf[i]!='\n'&&buf[i]!=0;j++,i++)
            {
                port[j]=buf[i];
            }
        }
        else if(strcmp(name,"threadNum")==0)
        {
            for(j=0,i++;i<sizeof(buf)&&buf[i]!='\n'&&buf[i]!=0;j++,i++)
            {
                tNum[j]=buf[i];
            }
            *threadNum=atoi(tNum);
        }
        bzero(buf,sizeof(buf));
        bzero(name,sizeof(name));

    }
    return 0;

}

